package com.afkt.project.ui.slice;

import com.afkt.project.base.app.BaseActivity;
import com.afkt.project.base.config.PathConfig;
import com.ohos.afkt.ResourceTable;
import com.dev.base.widget.BaseButton;
import com.dev.utils.app.ListenerUtils;
import ohos.agp.components.Component;
import ohos.media.image.PixelMap;

/**
 * detail:  CapturePictureActivity
 * @author Ttt
 */
public class CapturePictureActivity extends BaseActivity implements Component.ClickedListener {

    private BaseButton vidAcpScreenBtn;
    private BaseButton vidAcpScreen1Btn;
    private BaseButton vidAcpLinearBtn;
    private BaseButton vidAcpScrollBtn;
    private BaseButton vidAcpListBtn;
    private BaseButton vidAcpGridBtn;
    private BaseButton vidAcpRecyBtn;
    private BaseButton vidAcpWebviewBtn;


    @Override
    protected int baseLayoutId() {
        return ResourceTable.Layout_activity_capture_picture;
    }

    @Override
    protected void initView() {
        // ===========
        // = 截图方法 =
        // ===========

        vidAcpScreenBtn = (BaseButton) findComponentById(ResourceTable.Id_vid_acp_screen_btn);
        vidAcpScreen1Btn = (BaseButton) findComponentById(ResourceTable.Id_vid_acp_screen1_btn);
        vidAcpLinearBtn = (BaseButton) findComponentById(ResourceTable.Id_vid_acp_linear_btn);
        vidAcpScrollBtn = (BaseButton) findComponentById(ResourceTable.Id_vid_acp_scroll_btn);
        vidAcpListBtn = (BaseButton) findComponentById(ResourceTable.Id_vid_acp_list_btn);
        vidAcpGridBtn = (BaseButton) findComponentById(ResourceTable.Id_vid_acp_grid_btn);
        vidAcpRecyBtn = (BaseButton) findComponentById(ResourceTable.Id_vid_acp_recy_btn);
        vidAcpWebviewBtn = (BaseButton) findComponentById(ResourceTable.Id_vid_acp_webview_btn);

//        | snapshotWithStatusBar | 获取当前屏幕截图, 包含状态栏 ( 顶部灰色 TitleBar 高度, 没有设置 theme 的 NoTitleBar 时会显示 ) |
//        | snapshotWithoutStatusBar | 获取当前屏幕截图, 不包含状态栏  |
//        | enableSlowWholeDocumentDraw | 关闭 WebView 优化 |
//        | snapshotByWebView | 截图 WebView |
//        | snapshotByView | 通过 View 绘制为 Bitmap |
//        | snapshotByViewCache | 通过 View Cache 绘制为 Bitmap |
//        | snapshotByLinearLayout | 通过 LinearLayout 绘制为 Bitmap |
//        | snapshotByFrameLayout | 通过 FrameLayout 绘制为 Bitmap |
//        | snapshotByRelativeLayout | 通过 RelativeLayout 绘制为 Bitmap |
//        | snapshotByScrollView | 通过 ScrollView 绘制为 Bitmap |
//        | snapshotByHorizontalScrollView | 通过 HorizontalScrollView 绘制为 Bitmap |
//        | snapshotByNestedScrollView | 通过 NestedScrollView 绘制为 Bitmap |
//        | snapshotByListView | 通过 ListView 绘制为 Bitmap |
//        | snapshotByGridView | 通过 GridView 绘制为 Bitmap |
//        | snapshotByRecyclerView | 通过 RecyclerView 绘制为 Bitmap |

    }

    @Override
    protected void initListener() {
        ListenerUtils.setOnClicks(this,
                vidAcpScreenBtn, vidAcpScreen1Btn,
                vidAcpLinearBtn, vidAcpScrollBtn,
                vidAcpListBtn, vidAcpGridBtn,
                vidAcpRecyBtn, vidAcpWebviewBtn);
    }

    @Override
    public void onClick(Component component) {
        PixelMap pixelMap;
        boolean result;
        String filePath = PathConfig.AEP_DOWN_IMAGE_PATH;
        String fileName;

        switch (component.getId()) {
            case ResourceTable.Id_vid_acp_screen_btn:
                fileName = "screen.jpg";
                // pixelMap = CapturePictureUtils.snapshotWithStatusBar(CapturePictureActivity.this);
                // result = ImageUtils.saveBitmapToSDCardJPEG(bitmap, filePath + fileName);
                //ToastTintUtils.success(result+"保存成功\n" + (filePath + fileName)+ "保存失败");*/
        }
    }
}
